/* eep.h

Copyright (C) Alex S. (mailto: md5sum@alexsp.ru)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details
http://www.gnu.org/licenses/gpl-2.0.html.

You should have received a copy of the GNU General Public License
along with this program in the file gpl-2.0.txt;
if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/


#ifndef EEP_H_
#define EEP_H_

#define INIT_eep_pointer(p) p=&eep_array[0]
#define INIT_ram_pointer(p) p=&ram_array[0]
#define INC_eep_pointer(p) p=(p==&eep_array[NUM_POINT-1]?&eep_array[0]:p+1)
#define INC_ram_pointer(p) p=(p==&ram_array[NUM_POINT-1]?&ram_array[0]:p+1)
#define DEC_eep_pointer(p) p=(p==&eep_array[0]?&eep_array[NUM_POINT-1]:p-1)
#define DEC_ram_pointer(p) p=(p==&ram_array[0]?&ram_array[NUM_POINT-1]:p-1)

typedef struct{
	uint32_t to_time;
	uint16_t pressure;
	int8_t	term1;
	int8_t 	term2;
	uint16_t crc;
} value_array_t;

#define NUM_POINT 96

extern EEMEM value_array_t eep_array[NUM_POINT];
extern value_array_t ram_array[NUM_POINT];
extern uint8_t new_half_val;

uint8_t arrays_init();
void eep_save_set();

/*
#define EEP_DEF_VALUE {{1,7207,24,6,0},\
		{2,7215,13,9,0},\
		{3,7222,16,1,0},\
		{4,7230,4,-8,0},\
		{5,7237,16,15,0},\
		{6,7244,12,-1,0},\
		{7,7252,9,-9,0},\
		{8,7259,16,-5,0},\
		{9,7266,19,-1,0},\
		{10,7273,29,-6,0},\
		{11,7281,14,13,0},\
		{12,7288,26,3,0},\
		{13,7294,15,7,0},\
		{14,7301,14,-7,0},\
		{15,7308,28,0,0},\
		{16,7315,7,-7,0},\
		{17,7321,16,18,0},\
		{18,7327,0,11,0},\
		{19,7333,13,2,0},\
		{20,7340,26,10,0},\
		{21,7345,25,0,0},\
		{22,7351,18,13,0},\
		{23,7357,29,13,0},\
		{24,7362,18,0,0},\
		{25,7367,2,3,0},\
		{26,7372,1,12,0},\
		{27,7377,6,-5,0},\
		{28,7382,15,7,0},\
		{29,7386,13,17,0},\
		{30,7391,10,0,0},\
		{31,7395,10,4,0},\
		{32,7399,0,18,0},\
		{33,7402,24,19,0},\
		{34,7406,26,16,0},\
		{35,7409,4,-9,0},\
		{36,7412,10,14,0},\
		{37,7415,9,-5,0},\
		{38,7417,14,-8,0},\
		{39,7420,26,-10,0},\
		{40,7422,29,4,0},\
		{41,7423,13,-4,0},\
		{42,7425,11,13,0},\
		{43,7426,26,18,0},\
		{44,7428,29,14,0},\
		{45,7428,26,16,0},\
		{46,7429,24,-2,0},\
		{47,7429,6,18,0},\
		{48,7430,13,15,0},\
		{49,7429,25,-10,0},\
		{50,7429,20,0,0},\
		{51,7428,9,5,0},\
		{52,7428,21,0,0},\
		{53,7426,8,-6,0},\
		{54,7425,9,-1,0},\
		{55,7423,9,11,0},\
		{56,7422,10,7,0},\
		{57,7420,10,-8,0},\
		{58,7417,15,16,0},\
		{59,7415,26,-5,0},\
		{60,7412,24,19,0},\
		{61,7409,26,-3,0},\
		{62,7406,7,9,0},\
		{63,7402,24,18,0},\
		{64,7399,20,-4,0},\
		{65,7395,3,6,0},\
		{66,7391,29,19,0},\
		{67,7386,0,-9,0},\
		{68,7382,13,11,0},\
		{69,7377,13,-8,0},\
		{70,7372,27,-9,0},\
		{71,7367,13,-4,0},\
		{72,7362,27,-1,0},\
		{73,7357,9,15,0},\
		{74,7351,9,-6,0},\
		{75,7345,26,-7,0},\
		{76,7340,6,12,0},\
		{77,7333,4,3,0},\
		{78,7327,3,-9,0},\
		{79,7321,19,7,0},\
		{80,7315,29,3,0},\
		{81,7308,23,2,0},\
		{82,7301,29,-7,0},\
		{83,7294,5,17,0},\
		{84,7288,28,0,0},\
		{85,7281,0,-7,0},\
		{86,7273,18,-6,0},\
		{87,7266,12,-1,0},\
		{88,7259,26,6,0},\
		{89,7252,25,1,0},\
		{90,7244,8,12,0},\
		{91,7237,18,0,0},\
		{92,7230,3,-10,0},\
		{93,7222,19,18,0},\
		{94,7215,24,-6,0},\
		{95,7207,4,-5,0},\
		{96,7200,26,-9,0}}

*/
#endif /* EEP_H_ */
